import java.util.Scanner;
public class Main4{
    public static void main(String[] args){
        Scanner scanner=new Scanner(System.in);
        int n=scanner.nextInt();
        int x=scanner.nextInt();
        int num=0;
        for(int i=1;i<=n;i++){
            if(i<10&&i==x)num++;
            else if(i>=10){
                int j=i;
                while(j>0){
                    if(j%10==x)num++;
                    j/=10;
                }
            }
        }
        System.out.println(num);
    }
}